# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=py3-fonttools
_pkgname=fonttools
pkgver=4.34.4
pkgrel=0
pkgdesc="Converts OpenType and TrueType fonts to and from XML"
url="https://github.com/fonttools/fonttools"
arch="all"
license="MIT AND OFL-1.1"
depends="py3-lxml py3-fs"
makedepends="cython py3-build py3-installer py3-setuptools py3-wheel python3-dev"
checkdepends="py3-pytest py3-brotli"
subpackages="$pkgname-doc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/fonttools/fonttools/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-fonttools" # Backwards compatibility
provides="py-fonttools=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare
	# remove interpreter line
	sed -i '1d' Lib/fontTools/mtiLib/__init__.py
}

build() {
	python3 -m build --no-isolation --wheel .
}

check() {
	PATH="$PATH:$PWD" PYTHONPATH=$(echo "$PWD"/build/lib*) pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/fonttools-$pkgver-*.whl
}

doc() {
	replaces="py-$_pkgname-doc" # Backwards compatibility
	provides="py-$_pkgname-doc=$pkgver-r$pkgrel" # Backwards compatibility
	default_doc
}

sha512sums="
9c6ea7d6e9a9d74d2e705f7966853709ee834195f682bf595f932be2eab8fb728cf69b83680e5b95a308b40b1c17a7d1003efade9473d3f6d8e744ecfd1e2c62  fonttools-4.34.4.tar.gz
"
